package reflect;

import reflect.annotations.AutoRunClass;
import reflect.annotations.AutoRunMethod;

import java.lang.reflect.Member;
import java.lang.reflect.Method;

/**
 * @Classname: ReflectDemo9
 * @Author: bromide
 * @CreateTime: 2022/4/19--11:35
 * @Version: V1.0
 * @Description:
 */
public class ReflectDemo9 {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Person");
        Method[] methods = cls.getDeclaredMethods();
        for (Method method : methods) {
            /*
                除了类对象Class之外，像方法对象Method,属性对象Field等都有
                该方法，用于判断其表示的内容是否被某个注解标注了
             */
            if (method.isAnnotationPresent(AutoRunMethod.class)) {
                System.out.println(method.getName() + ":被@AutoRunMethod标注了");
            } else {
                System.out.println(method.getName() + ":没有被@AutoRunMethod标注");
            }
        }
    }
}
